package com.xinxin.leetcode.problem693;

import java.util.Stack;

/**
 * @author ShiXinXin
 * @date 2020-02-24 12:11
 */
class Solution {
    public boolean hasAlternatingBits(int n) {
        int temp = -1;
        while (n > 0) {
            if (n % 2 == temp) {
                return false;
            } else {
                temp = n % 2;
                n /= 2;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().hasAlternatingBits(5));
        System.out.println(new Solution().hasAlternatingBits(7));
        System.out.println(new Solution().hasAlternatingBits(11));
        System.out.println(new Solution().hasAlternatingBits(10));
    }
}
